package com.ewhale.feitengguest.ui.user.message.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ewhale.feitengguest.R;
import com.ewhale.feitengguest.dto.MessageDto;
import com.simga.library.adapter.recyclerview.BaseViewHolder;
import com.simga.library.adapter.recyclerview.MutiRecyclerAdapter;

import java.util.List;

import butterknife.BindView;

public class NewsBulletinAdapter extends MutiRecyclerAdapter<MessageDto> {



    public NewsBulletinAdapter(List<MessageDto> data) {
        super(data,R.layout.item_news_bulletin);
    }

    @Override
    protected BaseViewHolder<MessageDto> getViewHolder() {
        return new ViewHolder(view);
    }

    class ViewHolder extends BaseViewHolder<MessageDto> {
        @BindView(R.id.iv_icon)
        ImageView mIvIcon;
        @BindView(R.id.tv_title)
        TextView mTvTitle;
        @BindView(R.id.tv_time)
        TextView mTvTime;
        @BindView(R.id.tv_content)
        TextView mTvContent;
        public ViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void build(MessageDto object, int position) {
            if(object.getMessageType() == 2){
                mIvIcon.setImageResource(R.mipmap.c_icon_news);
            }else{
                mIvIcon.setImageResource(R.mipmap.c_icon_system);
            }
            mTvTitle.setText(object.getTitle());
            mTvTime.setText(object.getCreateTime());
            mTvContent.setText(object.getContent());
        }
    }
}
